package TankWar;

import java.awt.*;

public class Bullet {
    private int x;
    private int y;
    private Tank.Direction direction;
    private int speed;

    public Bullet(int x, int y, Tank.Direction direction) {
        this.x = x;
        this.y = y;
        this.direction = direction;
        this.speed = 10;
    }

    public void move() {
        // 根据方向和速度移动子弹的位置
        switch (direction) {
            case UP:
                y -= speed;
                break;
            case DOWN:
                y += speed;
                break;
            case LEFT:
                x -= speed;
                break;
            case RIGHT:
                x += speed;
                break;
        }
    }

    public void draw(Graphics g) {
        // 绘制子弹图形
        g.drawRect(x, y, 5, 5);
    }

    // 其他方法和属性的 getter 和 setter
    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public Tank.Direction getDirection() {
        return direction;
    }

    public int getSpeed() {
        return speed;
    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void setDirection(Tank.Direction direction) {
        this.direction = direction;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }
}
